#!/usr/bin/env python
from os import path
Import('build env module')

env.Append(CPPDEFINES=('KROLL_RUBY_API_EXPORT', 1))
build.add_thirdparty(env, 'poco')

if build.is_osx():
    env.Append(CPPPATH=[
        '/usr/lib/ruby/1.8/universal-darwin12.0',
        '/usr/lib/ruby/1.8/universal-darwin11.0',
        '/usr/lib/ruby/1.8/universal-darwin10.0',
        '/usr/lib/ruby/1.8/universal-darwin9.0',
        '/usr/lib/ruby/1.8/universal-darwin8.0',
        build.kroll_include_dir])
    env.Append(LIBS=['libruby'])


elif build.is_linux():
    env.Append(CPPPATH=[
        '/usr/lib/ruby/1.8/i386-linux',
        '/usr/lib/ruby/1.8/i486-linux',
        '/usr/lib/ruby/1.8/i686-linux',
        '/usr/lib/ruby/1.8/x86_64-linux',
        '/usr/lib/ruby/1.8/powerpc-linux',
        build.kroll_include_dir])

    if path.exists('/usr/lib/libruby1.8.so'):
        env.Append(LIBS=['ruby1.8'])
    else:
        env.Append(LIBS=['ruby'])

elif build.is_win32():
    env.Append(CPPPATH=[build.tp('ruby', 'lib', 'ruby', '1.8', 'i386-mswin32')])
    env.Append(LIBPATH=[build.tp('ruby', 'lib')])
    env.Append(LIBS=['msvcrt-ruby18'])

build.mark_build_target(env.SharedLibrary(
    path.join(module.dir, 'rubymodule'), Glob('*.cpp')))

if build.is_win32():
    build.utils.LightWeightCopy(build.tp('ruby'), module.dir)

